.class Lorg/springframework/util/AntPathStringMatcher;
.super Ljava/lang/Object;
.source "AntPathStringMatcher.java"


# static fields
.field private static final DEFAULT_VARIABLE_PATTERN:Ljava/lang/String; = "(.*)"

.field private static final GLOB_PATTERN:Ljava/util/regex/Pattern;


# instance fields
.field private final pattern:Ljava/util/regex/Pattern;

.field private str:Ljava/lang/String;

.field private final uriTemplateVariables:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private final variableNames:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 37
    const-string v0, "\\?|\\*|\\{([^/]+?)\\}"

    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lorg/springframework/util/AntPathStringMatcher;->GLOB_PATTERN:Ljava/util/regex/Pattern;

    .line 35
    return-void
.end method

.method constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V
    .locals 1
    .parameter "pattern"
    .parameter "str"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 50
    .local p3, uriTemplateVariables:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 45
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Lorg/springframework/util/AntPathStringMatcher;->variableNames:Ljava/util/List;

    .line 51
    iput-object p2, p0, Lorg/springframework/util/AntPathStringMatcher;->str:Ljava/lang/String;

    .line 52
    iput-object p3, p0, Lorg/springframework/util/AntPathStringMatcher;->uriTemplateVariables:Ljava/util/Map;

    .line 53
    invoke-direct {p0, p1}, Lorg/springframework/util/AntPathStringMatcher;->createPattern(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    iput-object v0, p0, Lorg/springframework/util/AntPathStringMatcher;->pattern:Ljava/util/regex/Pattern;

    .line 54
    return-void
.end method

.method private createPattern(Ljava/lang/String;)Ljava/util/regex/Pattern;
    .locals 10
    .parameter "pattern"

    .prologue
    const/4 v9, 0x1

    .line 57
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    .line 58
    .local v4, patternBuilder:Ljava/lang/StringBuilder;
    sget-object v7, Lorg/springframework/util/AntPathStringMatcher;->GLOB_PATTERN:Ljava/util/regex/Pattern;

    invoke-virtual {v7, p1}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v2

    .line 59
    .local v2, m:Ljava/util/regex/Matcher;
    const/4 v1, 0x0

    .line 60
    .local v1, end:I
    :goto_0
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->find()Z

    move-result v7

    if-nez v7, :cond_0

    .line 86
    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v7

    invoke-direct {p0, p1, v1, v7}, Lorg/springframework/util/AntPathStringMatcher;->quote(Ljava/lang/String;II)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 87
    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v7}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v7

    return-object v7

    .line 61
    :cond_0
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->start()I

    move-result v7

    invoke-direct {p0, p1, v1, v7}, Lorg/springframework/util/AntPathStringMatcher;->quote(Ljava/lang/String;II)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 62
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->group()Ljava/lang/String;

    move-result-object v3

    .line 63
    .local v3, match:Ljava/lang/String;
    const-string v7, "?"

    invoke-virtual {v7, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_2

    .line 64
    const/16 v7, 0x2e

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    .line 84
    :cond_1
    :goto_1
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->end()I

    move-result v1

    goto :goto_0

    .line 66
    :cond_2
    const-string v7, "*"

    invoke-virtual {v7, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_3

    .line 67
    const-string v7, ".*"

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    goto :goto_1

    .line 69
    :cond_3
    const-string v7, "{"

    invoke-virtual {v3, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v7

    if-eqz v7, :cond_1

    const-string v7, "}"

    invoke-virtual {v3, v7}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v7

    if-eqz v7, :cond_1

    .line 70
    const/16 v7, 0x3a

    invoke-virtual {v3, v7}, Ljava/lang/String;->indexOf(I)I

    move-result v0

    .line 71
    .local v0, colonIdx:I
    const/4 v7, -0x1

    if-ne v0, v7, :cond_4

    .line 72
    const-string v7, "(.*)"

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 73
    iget-object v7, p0, Lorg/springframework/util/AntPathStringMatcher;->variableNames:Ljava/util/List;

    invoke-virtual {v2, v9}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v8

    invoke-interface {v7, v8}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_1

    .line 76
    :cond_4
    add-int/lit8 v7, v0, 0x1

    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v8

    add-int/lit8 v8, v8, -0x1

    invoke-virtual {v3, v7, v8}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v6

    .line 77
    .local v6, variablePattern:Ljava/lang/String;
    const/16 v7, 0x28

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    .line 78
    invoke-virtual {v4, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 79
    const/16 v7, 0x29

    invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    .line 80
    invoke-virtual {v3, v9, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v5

    .line 81
    .local v5, variableName:Ljava/lang/String;
    iget-object v7, p0, Lorg/springframework/util/AntPathStringMatcher;->variableNames:Ljava/util/List;

    invoke-interface {v7, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_1
.end method

.method private quote(Ljava/lang/String;II)Ljava/lang/String;
    .locals 1
    .parameter "s"
    .parameter "start"
    .parameter "end"

    .prologue
    .line 91
    if-ne p2, p3, :cond_0

    .line 92
    const-string v0, ""

    .line 94
    :goto_0
    return-object v0

    :cond_0
    invoke-virtual {p1, p2, p3}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Ljava/util/regex/Pattern;->quote(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    goto :goto_0
.end method


# virtual methods
.method public matchStrings()Z
    .locals 6

    .prologue
    .line 103
    iget-object v4, p0, Lorg/springframework/util/AntPathStringMatcher;->pattern:Ljava/util/regex/Pattern;

    iget-object v5, p0, Lorg/springframework/util/AntPathStringMatcher;->str:Ljava/lang/String;

    invoke-virtual {v4, v5}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v1

    .line 104
    .local v1, matcher:Ljava/util/regex/Matcher;
    invoke-virtual {v1}, Ljava/util/regex/Matcher;->matches()Z

    move-result v4

    if-eqz v4, :cond_2

    .line 105
    iget-object v4, p0, Lorg/springframework/util/AntPathStringMatcher;->uriTemplateVariables:Ljava/util/Map;

    if-eqz v4, :cond_0

    .line 106
    const/4 v0, 0x1

    .local v0, i:I
    :goto_0
    invoke-virtual {v1}, Ljava/util/regex/Matcher;->groupCount()I

    move-result v4

    if-le v0, v4, :cond_1

    .line 112
    .end local v0           #i:I
    :cond_0
    const/4 v4, 0x1

    .line 115
    :goto_1
    return v4

    .line 107
    .restart local v0       #i:I
    :cond_1
    iget-object v4, p0, Lorg/springframework/util/AntPathStringMatcher;->variableNames:Ljava/util/List;

    add-int/lit8 v5, v0, -0x1

    invoke-interface {v4, v5}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    .line 108
    .local v2, name:Ljava/lang/String;
    invoke-virtual {v1, v0}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v3

    .line 109
    .local v3, value:Ljava/lang/String;
    iget-object v4, p0, Lorg/springframework/util/AntPathStringMatcher;->uriTemplateVariables:Ljava/util/Map;

    invoke-interface {v4, v2, v3}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 106
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 115
    .end local v0           #i:I
    .end local v2           #name:Ljava/lang/String;
    .end local v3           #value:Ljava/lang/String;
    :cond_2
    const/4 v4, 0x0

    goto :goto_1
.end method
